﻿namespace SKeeper.Application.ViewModels.Items
{
    using System;
    using Domain.Items;
    using SKeeper.Infrastructure;

    public class ItemViewModel
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public Tax Tax { get; set; }

        public ProductType Type { get; set; }

        public Units Unit { get; set; }

        public int CompanyId { get; set; }

        public static ItemViewModel FromItem(Item x)
        {
            return new ItemViewModel
            {
                CompanyId = x.CompanyId,
                Name = x.Name,
                Id = x.Id,
                Tax = x.Tax,
                Type = x.Type,
                Unit = x.Unit,
            };
        }

        public Item ToItem()
        {
            return new Item
            {
                CompanyId = this.CompanyId,
                Name = this.Name,
                Id = this.Id,
                Tax = this.Tax,
                Type = this.Type,
                Unit = this.Unit
            };
        }
    }
}
